<?php
echo $javascript->codeBlock("
	$(document).ready(function(){
		$('img#button_display_sallary').click(function(){
			if($('table#RelatedOrdersSeries tbody').css('visibility') == 'collapse'){
				status = 'visible';
			}else{
				status = 'collapse';
			}
			$('table#RelatedOrdersSeries tbody').css({'visibility':status});	
		});
		$('table#RelatedOrdersSeries tbody').css({'visibility':'collapse'});	
	});		
",$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));
?>

<div class="main_body">
    <?php echo $this->element('main_menu')?>		
	<div id="main_body_content">
			
		<div class="employees view">
		<h1><?php  __("Employee");?></h1>
			<dl><?php $i = 0; $class = ' class="altrow"';?>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Id"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['id']; ?>
					&nbsp;
				</dd>		
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("First Name"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['name']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Last Name"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['surname']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Address"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['address1']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Address cd."); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['address2']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("City"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['address3']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("State"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['address4']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Phone1"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['phone1']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Phone2"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['phone2']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Phone3"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['phone3']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Ssn Irs"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['ssn_irs']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Numer Id"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['numer_id']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Type Of Work"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['type_of_work_id']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Type Of Work 2"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['type_of_work_2_id']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Type Of Work 3"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['type_of_work_3_id']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Employment"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['date_of_employment']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("Employment End"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['Employee']['employment_end_date']; ?>
					&nbsp;
				</dd>
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __("E-mail"); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $employee['User']['email']; ?>
					&nbsp;
				</dd>				
			</dl>
		</div>

		<div class="clr"></div>
		
		<div class="related index">
			<h1><?php __("Related Orders");?></h1>
			<?php if (!empty($employee['Order'])):?>
			<table cellpadding = "0" cellspacing = "0">
			<tr>
				<th><?php __("Type Of Service"); ?></th>
				<th><?php __("Types Of Spaces"); ?></th>
				<th><?php __("Status"); ?></th>
				<th class="actions"><?php __("Actions");?></th>
			</tr>
			<?php
				$i = 0;
				foreach ($employee['Order'] as $order):
					$class = null;
					if ($i++ % 2 == 0) {
						$class = ' class="altrow"';
					}
				?>
				<tr<?php echo $class;?>>
					<td><?php echo $typeOfServices[$order['type_of_service_id']];?></td>
					<td><?php echo $typeOfSpaces[$order['types_of_spaces_id']];?></td>
					<td><?php echo $statusOfImplementation[$order['status_of_implementation']];?></td>
					<td class="actions">
						<?php echo $this->Html->link($html->image(HOST.'/actions_16_view.png'), array('controller' => 'orders', 'action' => 'view', $order['id']),array('title'=>__("View", true),'escape'=>false)); ?>
						<?php if($session->read('Auth.User.group') != 'emplo'){?>
						<?php echo $this->Html->link($html->image(HOST.'/actions_16_edit.png'), array('controller' => 'orders', 'action' => 'edit', $order['id']),array('title'=>__("Edit", true),'escape'=>false)); ?>
						<?php //echo $this->Html->link($html->image(HOST.'/actions_16_delete.png'), array('controller' => 'orders', 'action' => 'delete', $order['id']), array('title'=>__("Delete", true),'escape'=>false), sprintf(__("Are you sure you want to delete # %s?", true), $order['id'])); ?>
						<?php }?>
					</td>
				</tr>
			<?php endforeach; ?>
			</table>
		<?php endif; ?>

		</div>		
		<div class="clr"></div>
		<fieldset>
	 		<legend><h1><?php __("The amount to be paid"); ?></h1></legend>
	 		<div style="float: right;"><h2><?php echo $EmployeeSalary['0']['employee_salary']?> USD</h2></div>
		 </fieldset>
		
		
		<div class="clr"></div>
		
		<div class="related index">
			<h1><?php __("Related Orders Series");?></h1>
			<?php if (!empty($employee['OrdersSeries'])):?>
			<table cellpadding = "0" cellspacing = "0" id="RelatedOrdersSeries">
			<thead>
			<tr>
				<th><?php __("Orders Id"); ?></th>
				<th><?php __("Execution Date"); ?></th>
				<th><?php __("Salary"); ?></th>
				<th><?php __("Status"); ?></th>				
				<th class="actions"><?php echo $html->image(HOST.'/actions_series_display.png',array('id'=>'button_display_sallary','style'=>'cursor: pointer','title'=>__("Display Sallary",true)))?></th>
			</tr>
			</thead>
			<tbody>
			<?php
				$i = 0;
				foreach ($employee['OrdersSeries'] as $ordersSeries):
					$class = null;
					if ($i++ % 2 == 0) {
						$class = ' class="altrow"';
					}
				?>
				<tr<?php echo $class;?>>
					<td><?php echo $ordersSeries['orders_id'];?></td>
					<td><?php echo $ordersSeries['execution_date'];?></td>
					<td align="right"><?php echo $ordersSeries['employee_salary'];?></td>
					<td>
						<?php echo $html->image(HOST.'/actions_16_status_'.$ordersSeries['status'].'.png',array('title'=>$statusOfImplementation[$ordersSeries['status']])); ?>
						<?php echo $html->image(HOST.'/actions_16_status_payment_'.$ordersSeries['payment_status'].'.png',array('title'=>$paymentStatus[$ordersSeries['payment_status']])); ?>
						<?php 
							$statut = (!empty($ordersSeries['orders_billing_id']) && $ordersSeries['orders_billing_id'] > 0) ? 'yes' : 'no';
							$title = (!empty($ordersSeries['orders_billing_id']) && $ordersSeries['orders_billing_id'] > 0) ? __("Remuneration paid",true) : __("Remuneration is not paid",true);
							echo $html->image(HOST."/actions_16_status_payment_employee_{$statut}.png",array('title'=>$title)); ?> 
					</td>
					<td class="actions">
						<?php echo $this->Html->link($html->image(HOST.'/actions_16_view.png'), array('controller' => 'orders_series', 'action' => 'view', $ordersSeries['id']),array('title'=>__("View", true),'escape'=>false)); ?>
						<?php if($session->read('Auth.User.group') != 'emplo'){?>
						<?php echo $this->Html->link($html->image(HOST.'/actions_16_edit.png'), array('controller' => 'orders_series', 'action' => 'edit', $ordersSeries['id']),array('title'=>__("Edit", true),'escape'=>false)); ?>
						<?php echo $this->Html->link($html->image(HOST.'/actions_16_delete.png'), array('controller' => 'orders_series', 'action' => 'delete', $ordersSeries['id']), array('title'=>__("Delete", true),'escape'=>false), sprintf(__("Are you sure you want to delete # %s?", true), $ordersSeries['id'])); ?>
						<?php }?>
					</td>
				</tr>
			<?php endforeach; ?>
			</tbody>
			</table>
		<?php endif; ?>
		</div>
		<br/>
		
		
		<div class="clr"></div>	
	</div>			
	<?php echo $this->element('languages')?>	
	<div class="clr"></div>
</div>	
<div class="clr"></div>	
<div class="main_action">
	<div class="main_action_content">
			
		<div class="actions">
			<h3><?php __("Actions"); ?></h3>
			<ul>
				<?php if($session->read('Auth.User.group') == 'admin' || $session->read('Auth.User.group') == 'manag' ){?>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_employee_edit.png'), array('action' => 'edit', $employee['Employee']['id']),array('title'=>__("Edit Employee", true),'escape'=>false)); ?><div class="clr"></div><?php echo __("Edit Employee", true)?> </li>				
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_employee_delete.png'), array('action' => 'delete', $employee['Employee']['id']), array('title'=>__("Delete Employee", true),'escape'=>false), sprintf(__("Are you sure you want to delete # %s?", true), $employee['Employee']['id'])); ?><div class="clr"></div><?php echo __("Delete Employee", true)?> </li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_employees.png'), array('action' => 'index'),array('title'=>__("List Employees", true),'escape'=>false));?><div class="clr"></div><?php echo __("List Employees", true)?></li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_works_list.png'), array('controller' => 'type_of_works', 'action' => 'index'),array('title'=>__("List Type Of Work", true),'escape'=>false)); ?><div class="clr"></div> <?php echo __("List Type Of Work", true)?></li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_series.png'), array('controller' => 'orders_series', 'action' => 'index'),array('title'=>__("List Orders Series", true),'escape'=>false)); ?> <div class="clr"></div> <?php echo __("List Orders Series", true)?></li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_orders_list.png'), array('controller' => 'orders', 'action' => 'index'),array('title'=>__("List Orders", true),'escape'=>false)); ?><div class="clr"></div><?php echo __("List Orders", true)?> </li>
				<?php }?>
			</ul>
		</div>
		
		<div class="clr"></div>
	</div>		
</div>	

